<html>
<head>
<meta http-equiv="Pragma" content="no-cache"/>
<meta http-equiv="Cache-Control" content="no-cache"/>
<meta http-equiv="Expires" content="-1" />
<title>Web Services - Sample 15: Launching PyMOL on Demand</title>

<style><!--
a{text-decoration:none;
  padding: 1px;
  background-color: #dddddd}
--></style>

<script src="json2.js"></script> 
<script src="pymol.js"></script>

<script type="text/javascript">

var pymol8085 = new PyMOL('localhost', 8085, 'on');

var pymol8086 = new PyMOL('localhost', 8086, 'on');

function launchPymol(port) {
  var iframe = document.getElementById("iframe"+port);
  iframe.src = "start"+port+".pwg";
}

function quitPymol(port) {
  var iframe = document.getElementById("iframe"+port);
  iframe.src = "http://localhost:"+port+"/apply/_quit";
}

function usePymol8085() {
  pymol8085.cmd.reinitialize();
  pymol8085.cmd.load("$PYMOL_PATH/test/dat/1tii.pdb");
  pymol8085.cmd.show_as("cartoon");
  pymol8085.flush();
}

function usePymol8086() {
  pymol8086.cmd.reinitialize();
  pymol8086.cmd.load("$PYMOL_PATH/test/dat/il2.pdb");
  pymol8086.cmd.show_as("cartoon");
  pymol8086.flush();
}

</script>

</head>
<body>

<h3>Web Services - Sample 15: Launching PyMOL on Demand</h3>


<a href="javascript:window.close()">Close Window</a> (FireFox only: <a href="javascript:void(0)" onclick="window.open('view-source:' + location.href)">view page source</a>)

<p>So far, all of the examples have launched PyMOL at the time the web
page was opened.  However, this isn't necessary: with a multi-origin
application, or or more instances of PyMOL can be launched on demand,
each on its own port, simply by populating an IFRAME with a PWG
file.</p>

<pre>
<a href="javascript:launchPymol(8085)">launchPymol(8085)</a>  <a href="javascript:launchPymol(8086)">launchPymol(8086)</a> 


 <a href="javascript:usePymol8085()">usePymol8085()</a>     <a href="javascript:usePymol8086()">usePymol8086()</a>


<a href="javascript:quitPymol(8085)">quitPymol(8085)</a>    <a href="javascript:quitPymol(8086)">quitPymol(8086)</a> 
</pre>

<p>In addition launching multiple simultaneous PyMOL instances, this
sample application also demonstrates the use of the "options" keyword
in the associated PWG files, which is being used to modify the startup
configuration of PyMOL so as to launch as a simple 3D viewer window.
A restricted subset of standard PyMOL command-line arguments are
available for such customization tasks.  For information on launch options,
please refer to the <a href="http://pymol.org/dsc/dokuwiki/doku.php?id=launch">Official
PyMOL Documentation</a>.</p>

<p>startup8085.pwg</p>

<pre>
port 8085
options -qxie -F 0 -X 10 -Y 50 -W 250 -H 250 
</pre>

<p>startup8085.pwg</p>
<pre>
port 8086
options -qxi -F 0 -X 10 -Y 350 -W 250 -H 250
</pre>

<!-- the only purpose of these IFRAMEs is to launch PyMOL via the PWG
  -- helper mechanism -->

<iframe src="" id="iframe8085" name="iframe8085" onLoad=""
 width="0" height="0" frameborder="0"
 marginheight="0" marginwidth="0"
 scrolling="auto"></iframe>

<iframe src="" id="iframe8086" name="iframe8086" onLoad=""
 width="0" height="0" frameborder="0"
 marginheight="0" marginwidth="0"
 scrolling="auto"></iframe>

</body>
</html>
